<?php
//Operasi class for monitoring
class MonitoringOperasi extends Transaksi
{
	//external attributes
	public $pos;
	public $pos_sub;
	public $pos_keterangan;
	public $tanda_terima;
	public $nota_divmum;
	
	public function rules() {
		$rules = parent::rules();
		$rules[] = array('pos, pos_sub, pos_keterangan, tanda_terima, nota_divmum', 'safe', 'on'=>'search');
		
		return $rules;
	}
	
	public function searchSKI($nilai_divisi, $nilai_status) {
		$criteria=new CDbCriteria;

		$criteria->with = array('transaksiOperasis', 'transaksiAtributs' ,'idStatus');
		$criteria->with[] = 'transaksiOperasis.idPagu';
		$criteria->with[] = 'transaksiOperasis.idPagu.idPos';
		$criteria->with[] = 'transaksiOperasis.idPagu.idPos.idKet';
		
		$criteria->compare('id_divisi',$nilai_divisi);
		
		$criteria->compare('jenis_pos',$this->pos,true);
		$criteria->compare('jenis_subpos',$this->pos_sub,true);
		$criteria->compare('idKet.keterangan',$this->pos_keterangan,true);
		$criteria->compare('pekerjaan',$this->pekerjaan,true);
		$criteria->compare('rekanan',$this->rekanan,true);
		$criteria->compare('kurs',$this->kurs,true);
		$criteria->compare('nilai',$this->nilai,true);
		$criteria->compare('nilai_rupiah',$this->nilai_rupiah,true);
		$criteria->compare('transaksiAtributs.nota_divmum_no',$this->nota_divmum,true);
		$criteria->compare('transaksiOperasis.tanda_terima',$this->tanda_terima,true);
		
		$criteria->compare('idStatus.keterangan',$nilai_status);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
			'pagination' => array (
                  'pageSize' => 30,
            ),
			'sort'=>array(
            	'defaultOrder'=>'t.id ASC',
        	),
		));
	}
	
	public function searchOperasiPending($nilai_divisi) {
		return $this->searchSKI($nilai_divisi, 'Pending');
	}
	
	public function searchOperasiApproved($nilai_divisi) {
		return $this->searchSKI($nilai_divisi, 'Approved');
	}
	
	public function searchOperasiRejected($nilai_divisi) {
		return $this->searchSKI($nilai_divisi, 'Rejected');
	}
}
?>